# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：   za_email
   Author :      wuqianyong
   date：        2019/12/13
-------------------------------------------------
   Change Activity:
                   2017/4/1:
-------------------------------------------------
Description :
 

"""
__author__ = 'wuqianyong'
import time
from extra_apps.get_md5 import get_md5
import requests
from extra_apps.common_log import Log


def za_send_email(title, msg, to=None):
    secret_key = "12398***(()&&###KKJiijlllNN!~!@!@"
    real_url = "https://mip.zhongan.com"
    if not to:
        to = "wuqianyong@zhongan.com"
    now_time = int(1000 * time.time())
    # title = "测试1213"
    # content= "延误7号线"
    sign_str = "{}{}{}".format(now_time, to, secret_key)
    # Log.info(sign_str)
    sign = get_md5(content=sign_str).upper()
    # print(sign)
    url = "{}/email/sendMail?to={}&title={}&content={}&time={}&sign={}".format(real_url, to, title, msg, now_time, sign)
    Log.info("发送邮件url:{}".format(url))
    resp = requests.get(url)
    Log.info("邮件发送结果：{}".format(resp.text))


if __name__ == '__main__':
    za_send_email(title="地铁延误预警",msg="地铁7号线延误")
